home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Symantec Versions / C04 Speech / P02 Wait Speech / WaitSpeech.c next >
Encoding:
Text File  |  1995-08-31  |  1.9 KB  |  92 lines  |  [TEXT/KAHL]

  1. //____________________________________________________________
  2. //    WaitSpeech.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Speech.h>
  13.  
  14.  
  15. //____________________________________________________________
  16.  
  17. void     InitializeToolbox( void );
  18. Boolean  IsSpeechAvailable( void );
  19.  
  20.  
  21. //____________________________________________________________
  22.  
  23. void  main( void )
  24.    Str255   theString = "\pThis is the second string";
  25.    OSErr    theError;
  26.    Boolean  speechPresent;
  27.    
  28.    InitializeToolbox();
  29.  
  30.    speechPresent = IsSpeechAvailable();
  31.    if ( speechPresent == false )
  32.       ExitToShell();
  33.  
  34.    theError = SpeakString( "\pThis is string #1" );
  35.    if ( theError != noErr )
  36.       ExitToShell();
  37.  
  38.    while ( SpeechBusy() == true )
  39.       ;
  40.       
  41.    theError = SpeakString( theString );
  42.    if ( theError != noErr )
  43.       ExitToShell();
  44.       
  45.    // ** if you comment out the following two lines and recompile, **
  46.    // ** you might not hear speech when the program runs - the     **
  47.    // ** program may exit before playing the string                **
  48.    
  49.    while ( SpeechBusy() == true )
  50.       ;
  51.  
  52. }
  53.  
  54.  
  55. //____________________________________________________________
  56.  
  57. Boolean  IsSpeechAvailable( void )
  58. {
  59.    OSErr    theError;
  60.    long     theResult;
  61.    Boolean  speechAvail;
  62.    
  63.    theError = Gestalt( gestaltSpeechAttr, &theResult );
  64.    if ( theError != noErr )
  65.       ExitToShell();
  66.       
  67.    speechAvail = theResult & ( 1 << gestaltSpeechMgrPresent );  
  68.    if ( speechAvail > 0 )
  69.       return ( true );
  70.    else
  71.       return ( false );
  72. }
  73.  
  74.  
  75. //____________________________________________________________
  76.  
  77. void  InitializeToolbox( void )
  78. {
  79.    InitGraf( &qd.thePort );
  80.    InitFonts();
  81.    InitWindows();
  82.    InitMenus();
  83.    TEInit();
  84.    InitDialogs( 0L );
  85.    FlushEvents( everyEvent, 0 );
  86.    InitCursor();
  87. }
  88.  
  89.  
  90.  
  91.